package com.ruoyi.biz.service.impl;

import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.apache.commons.lang3.StringUtils;
import com.ruoyi.biz.mapper.TscSignalMapper;
import com.ruoyi.biz.domain.TscSignal;
import com.ruoyi.biz.service.ITscSignalService;

import java.util.List;

/**
 * 交通信号灯设备Service业务层处理
 *
 * @author ruoyi
 * @date 2021-04-26
 */
@Service
public class TscSignalServiceImpl extends ServiceImpl<TscSignalMapper, TscSignal> implements ITscSignalService {

    @Override
    public List<TscSignal> queryList(TscSignal tscSignal) {
        LambdaQueryWrapper<TscSignal> lqw = Wrappers.lambdaQuery();
        if (tscSignal.getDeviceId() != null){
            lqw.eq(TscSignal::getDeviceId ,tscSignal.getDeviceId());
        }
        if (StringUtils.isNotBlank(tscSignal.getDeviceName())){
            lqw.like(TscSignal::getDeviceName ,tscSignal.getDeviceName());
        }
        if (StringUtils.isNotBlank(tscSignal.getDeviceType())){
            lqw.eq(TscSignal::getDeviceType ,tscSignal.getDeviceType());
        }
        if (tscSignal.getType() != null){
            lqw.eq(TscSignal::getType ,tscSignal.getType());
        }
        if (tscSignal.getState() != null){
            lqw.eq(TscSignal::getState ,tscSignal.getState());
        }
        return this.list(lqw);
    }
}